<<<<<<< HEAD
=======
<<<<<<< HEAD
=======
<template>
  <div class="peopleSZ">
    <el-header style="height: 110px;background-color: white">
      <div class="permission_text">员工基础设置</div>
      <div class="Breadcrumb"><span>首页</span><span>/</span><span>员工基础设置</span></div>
    </el-header>

    <div class="btn">

      <el-button type="success text" @click="dialogVisible1 = true"v-on:click="addfenzu">添加员工</el-button>
      <el-button type="danger" @click="dialogVisible = true" v-on:click="addGroup">设置分组</el-button>
      <router-view></router-view>
    </div>
    <!--展示列表-->
    <el-table
      :data="tableData"
      style="width: 100%">

      <el-table-column
        type="selection">

      </el-table-column>
      <el-table-column
        prop="employee_id"
        label="序号"
        type="index"
        width="120">
      </el-table-column>
      <el-table-column
        prop="employee_name"
        label="姓名"
        width="120">
      </el-table-column>
      <el-table-column
        prop="headquartersStore.headquarters_store_name"
        label="所属门店"
        width="120">
      </el-table-column>
      <el-table-column
        prop="employee_code"
        label="员工编码"
        width="120">
      </el-table-column>
      <el-table-column
        prop="employeeGroup.employee_group_name"
        label="组名"
        width="120">
      </el-table-column>
      <el-table-column
        prop="employee_user_name"
        label="用户名"
        width="120">
      </el-table-column>
      <el-table-column
        prop="role.rname"
        label="角色"
        width="120">
      </el-table-column>
      <el-table-column
        prop="employee_card"
        label="身份证号"
        width="120">
      </el-table-column>
      <el-table-column
        prop="employee_tel"
        label="联系电话"
        width="120">
      </el-table-column>
      <el-table-column
        prop="employee_status"
        label="当前状态"
        width="120">
      </el-table-column>
      <el-table-column
        prop="operation"
        label="操作"
        width="120"
        fixed="right">
        <template slot-scope="scope">
          <el-button @click="deleteuser(scope.row.employee_id,scope.$index)" type="text" size="small">删除</el-button>
          <el-button type="text"  size="small" @click="deleltuser2">编辑</el-button>
        </template>

      </el-table-column>
    </el-table>

    <!--//添加员工-->
    <el-dialog
      class="btnadd"
      title="增加员工"
      :visible.sync="dialogVisible1"
      width="65%"
      :before-close="handleClose">
      <span></span>
      <!--<p>员工编码：<input type="text" class="staffNumber"></p>-->
      <!--<p>员工姓名：<input type="text" class="staffname"></p>-->
      <!--<p>所属分店：<input type="text" class="staffshop"></p>-->
      <table>
        <tr class="tr1">
          <th ><p>员工编码：<input type="text" v-model="employee_number" ></p></th>
          <th><p>用户名：<input type="text"  v-model="user_name"></p></th>
          <th><p>角色名称：<select>
            <option value="volvo"v-for="item in rnamelist" v-model="rolename">{{item}}</option>
            <!--<option value="volvo">Volvo</option>-->
            <!--<option value="volvo">Volvo</option>-->
          </select></p></th>
        </tr>
        <tr>
          <th><p>员工姓名：<input  type="text" v-model="name" ></p></th>
          <th><p>身份证号：<input type="text" v-model="id_number" ></p></th>
          <th><p>联系电话：<input type="text" v-model="telephone" ></p></th>
        </tr>
        <tr>
          <th><p>所属分店：<select>
            <option value="volvo" v-for="item in headquarterslist" v-model="groupname">{{item}}</option>
            <!--<option value="volvo">Volvo</option>-->
            <!--<option value="volvo">Volvo</option>-->
          </select></p></th>
          <th><p>所属分组：<select>
            <option value="volvo" v-for="item in grouplist2" v-model="headquartersStorename">{{item}}</option>
            <!--<option value="volvo">Volvo</option>-->
            <!--<option value="volvo">Volvo</option>-->
          </select></p></th>
          <th style="text-align: left"><p>在职状态：<input type="radio" name="1" >在职
            <input type="radio" name="1" >离职
          </p></th>
        </tr>
      </table>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible1 = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible1 = false" v-on:click="adduser" >确 定</el-button>
  </span>
    </el-dialog>


    <!--//设置分组-->
    <el-dialog
      title="设置分组"
      :visible.sync="dialogVisible"
      width="65%"
      :before-close="handleClose">
      <el-button type="danger" @click="dialogVisible2 = true">添加分组</el-button>
      <template>
        <el-table
          :data="tableData2"
          style="width: 100%">
          <el-table-column
            prop="employee_group_id"
            label="序号"
            width="180">
          </el-table-column>
          <el-table-column
            prop="employee_group_name"
            label="分组名称"
            width="180">
          </el-table-column>
          <el-table-column
            prop="employee_group_remarks"
            label="分组备注">
          </el-table-column>
          <el-table-column
            prop="address"
            label="操作">
          </el-table-column>
        </el-table>
      </template>
      <!--<table class="SZFZ">-->
      <!--<tr>-->
      <!--<th>序号</th>-->
      <!--<th>分组名称</th>-->
      <!--<th>分组备注</th>-->
      <!--<th>所属分店</th>-->
      <!--<th>操作</th>-->
      <!--</tr>-->
      <!--</table>-->
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>

    <!--添加分组-->
    <el-dialog
      title="新建分组"
      :visible.sync="dialogVisible2"
      width="50%"
      :before-close="handleClose">
      分组名称：<input type="text" v-model="Group_name">
      分组备注：<input type="text" v-model="Group_remarks">
      分组ID：<input type="text" v-model="Branch_store">
      <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="dialogVisible2 = false"v-on:click="addGroupname" >确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script type="text/babel">


export default {
  name: "employee_basics",
  data(){
    return{
      dialogVisible1: false,
      dialogVisible2: false,
      dialogVisible: false,
      tableData:[],
      tableData2:[],
      gruoplist:[],
      grouplist2:[],
      temp :[],
      headquarterslist:[],
      rnamelist:[],
//            serial_number:"",

      user_name:"",//员工用户名
      employee_number:"",//员工编号
      name:"",//员工姓名
      id_number:"",//身份证号
      telephone:"",//电话
      groupname:"",//组名
      headquartersStorename:"",//所属门店
      jobonline:"",//在职状态
      rolename:"",//角色状态

      Group_name:"",//分组名称
      Group_remarks:"",//分组备注
      Branch_store:"",//分组ID

    }
  },
  methods: {
    open() {
      this.$alert('<strong></strong>', 'HTML 片段', {
        dangerouslyUseHTMLString: true
      });
    },
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done();
        })
        .catch(_ => {});
    },
    adduser(){
      var obj=new Object();

      obj.employee_name=this.name;
      obj.employee_code=this.employee_number;
      obj.employee_user_name=this.user_name;
      obj.employee_tel=this.telephone;
//              obj.employeeGroup.employee_group_name=this.groupname;

      console.log(this.user_name);
      this.tableData.push(obj);
      this.$axios.post("http://172.16.6.69:8080/employee_manager/add_employee",obj,{
        transformRequest:[
          function(data){
            let params = "";
            var arr = [];
            for(var key in data){
              arr.push(key+"="+data[key]);
            }
            params = arr.join("&");
            return params;
          }
        ]

      }).then(
        (res)=>{
          console.log("添加成功");
        }
      )
    },
    addGroup(){
      this.$axios.post("http://172.16.6.69:8080/group/findAll").then(
        (res)=>{
          console.log(2222)
          console.log(res.data.data)
          this.tableData2=res.data.data
        }
      ).catch(
        (err)=>{

        }
      )
    },
    handleClick(row) {
      console.log(row);
    },
    deleteuser(employee_id,index){
      console.log(index);
      this.tableData.splice(index,1)

      console.log(this.tableData);
      console.log(employee_id);
      let obj=new Object();
      obj.employee_id=employee_id;
//            console.log(index);
//            obj.employee_id=res.data.data.data.employee_id;
      console.log(obj);
      this.$axios.post("http://172.16.6.69:8080/employee/delete",obj,
        {
          transformRequest:[
            function(data){
              let params = "";
              var arr = [];
              for(var key in data){
                arr.push(key+"="+data[key]);
              }
              params = arr.join("&");
              return params;
            }
          ]
        },
        {
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }
      ).then(function(res){
          console.log("删除成功")
//              console.log(res)

        }
      );
    },

    addGroupname(){
      let obj=new Object();
      obj.employee_group_name=this.Group_name;
      obj.employee_group_remarks=this.Group_remarks;
      obj.employee_group_id=this.Branch_store;
      console.log(obj);
      this.$axios.post("http://172.16.6.69:8080/group/add",obj,
        {
          transformRequest:[
            function(data){
              let params = "";
              var arr = [];
              for(var key in data){
                arr.push(key+"="+data[key]);
              }
              params = arr.join("&");
              return params;
            }
          ]
        },{
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }
      ).then(
        (res)=>{
          console.log(333);
          console.log(res);
          console.log("添加分组成功");
        }
      )

    },
    deleltuser2(){
      var obj=new Object();

      obj.id=1;
//              obj.employeeGroup.employee_group_name=this.groupname;

      console.log(this.user_name);
      this.tableData.push(obj);
      this.$axios.post("http://172.16.6.69:8080/employee/delete",obj,{
        transformRequest:[
          function(data){
            let params = "";
            var arr = [];
            for(var key in data){
              arr.push(key+"="+data[key]);
            }
            params = arr.join("&");
            return params;
          }
        ]
      },{
        headers : {
          'Content-Type':'application/x-www-form-urlencoded'
        }
      }).then(
        (res)=>{
          console.log("添加成功");
        }
      )
    },
    addfenzu(){
      this.$axios.post("http://172.16.6.69:8080/employee/group_role_hq").then(
        (res)=>{
          this.grouplist2=[];
          this.headquarterslist=[];
          this.rnamelist=[];
          console.log(res.data.data);
          for(var i=0;i<res.data.data.group.length;i++){
            this.grouplist2.push(res.data.data.group[i].employee_group_name)
          }
          for(var z=0;z<res.data.data.headquarters.length;z++){
            this.headquarterslist.push(res.data.data.headquarters[z].headquarters_store_name)
          }
          for (var y=0;y<res.data.data.role.length;y++){
            this.rnamelist.push(res.data.data.role[y].rname)
          }
          console.log(this.grouplist2)
          console.log(this.headquarterslist)
          console.log(this.rnamelist)
        }
      )
    }
  },

  beforeMount:function(){
//        this.$axios.post(this.$api.employee_basics.employee)
//          .then(
//          (response)=>{
//            console.log(123);
//            console.log(response);
//            this.tableData=response.data;
//          }
//        ).catch(
//          (err)=>{
//            console.log(err);
//          }
//        )
    this.$axios.post("http://172.16.6.69:8080/employee_manager/all_employee",{
      transformRequest:[
        function(data){
          let params = "";
          var arr = [];
          for(var key in data){
            arr.push(key+"="+data[key]);
          }
          params = arr.join("&");
          return params;
        }
      ]
    }).then
    (
      (res)=>{
        console.log(123);
        if(res.data.code == 200){
          this.tableData=res.data.data.data;
              console.log(111111)
             console.log(res);
          for (var i=0;i<res.data.data.data.length;i++){
//                console.log(res.data.data.data[i].employeeGroup.employee_group_name);
            var groupname=res.data.data.data[i].employeeGroup.employee_group_name;
//                console.log(groupname)
            this.gruoplist.push(groupname)
            for(var z = 0; z < this.gruoplist.length; z++){
              if(this.temp.indexOf(this.gruoplist[z]) == -1){
                this.temp.push(this.gruoplist[z]);
//                    console.log(this.temp)
              }
            }
          }
        }
      }).catch(
      (err)=>{
//            console.log(err);
      }
    );

//        this.$axios.post("http://172.16.6.69:8080/employee/group_role_hq").then(
//          (res)=>{
//            console.log(res.data.data)
//            for(var i=0;i<res.data.data.group.length;i++){
//              this.grouplist2.push(res.data.data.group[i].employee_group_name)
//            }
//            for(var z=0;z<res.data.data.headquarters.length;z++){
//              this.headquarterslist.push(res.data.data.headquarters[z].headquarters_store_name)
//            }
//            for (var y=0;y<res.data.data.role.length;y++){
//              this.rnamelist.push(res.data.data.role[y].rname)
//            }
//            console.log(this.grouplist2)
//            console.log(this.headquarterslist)
//            console.log(this.rnamelist)
//          }
//        )
  }
}
</script>

<style scoped>
  .peopleSZ{
    width: 84%;
    background-color: white;
  }
  h2{
    margin-left: 30px;
    margin-top: 30px;
  }
  hr{
    margin-bottom: 30px;
  }
  .btn{
    margin-bottom: 20px;
    margin-left: 30px;
  }
  .staffadd{

  }
  .btnadd{
  }
  table tr{
    height: 50px;
  }
  table p{
    margin-right: 30px;
  }
  table select{
    height: 20px;
    width: 175px;
  }
  .SZFZ{
    width: 100%;
  }

  .SZFZ tr th{
    /*margin-left: 100px;*/
  }

  .box {
    background-color: #f6f6f6;
    width: 85%;
    min-height: 600px;
  }

  .table_pad {
    margin-left: 35px;
    margin-top: 40px;
  }

  .permission_text {
    font-size: 30px;
    padding-top: 20px;
    padding-left: 15px;
  }

  .subhead {
    font-size: 24px;
  }

  .line {
    margin-top: 10px;
    margin-bottom: 30px;
    border-top: 1px solid #DADADA;
  }

  .Breadcrumb {
    font-size: 12px;
    margin-top: 10px;
    margin-left: 10px;
    color: #999999;
  }

  .Breadcrumb span {
    margin-left: 10px;
  }

  .Breadcrumb span:nth-of-type(1), .Breadcrumb span:nth-of-type(3) {
    color: #3380FF;
  }

  table.gridtable {
    font-family: verdana, arial, sans-serif;
    color: #333333;
    border-width: 1px;
    border-color: #666666;
    border-collapse: collapse;
    text-align: center;
  }

  table.gridtable th {
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: #ECEEF5;
    width: 300px;
    background-color: #F2F2F2;
  }

  table.gridtable td {
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: #ECEEF5;
    font-size: 11px;
  }
</style>
>>>>>>> 7c9b4d15691d11e5112d7fe55896e17d687e8a13
<<<<<<< HEAD
>>>>>>> 228a02d38f1996584d41d85ae19c7aec6c68f03e
=======
>>>>>>> 24587799dfafcf2d613b6ed8fee01832b42aacad
>>>>>>> 01f83abbe9f4f27cbff2bc81b083d5f58836dac9
>>>>>>> 7f3d74c8e1094d8c3383b1c2e8137703cf69752f
